<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8" />
        <title>PythonTutorials</title>
        <link rel="stylesheet" href="/theme/css/main.css" />

        <!--[if IE]>
            <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
</head>

<body id="index" class="home">
        <header id="banner" class="body">
                <h1><a href="/">PythonTutorials </a></h1>
                <nav><ul>
                    <li><a href="/category/cpp.html">cpp</a></li>
                    <li><a href="/category/python.html">python</a></li>
                </ul>
                </nav>
        </header><!-- /#banner -->

                <section id="content" class="body">
                    <ol id="posts-list" class="hfeed" start="2">
            <li><article class="hentry">
                <header>
                    <h1><a href="/chapter8-2.html" rel="bookmark"
                           title="Permalink to chapter8-2">chapter8-2</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <h1>说明：</h1>
<ul>
<li>
<p>int fun(int a[10]) 等价于 int fun(int *a) 等价于 int fun(int a[])</p>
</li>
<li>
<p>若数组作为形参，则将数组名做指针变量来处理</p>
</li>
<li>&amp;与*互为逆运算符</li>
<li>*与[] 等价</li>
<li>&amp;与[] 互为逆运算</li>
</ul>
<h1>指向一维数组的指针变量</h1>
<div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;string.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;stdlib.h&gt;</span><span class="cp"></span>
<span class="cp">#define N 5</span>
<span class="kt">void</span> <span class="nf">array</span><span class="p">(</span><span class="kt">int</span> <span class="n">number</span><span class="p">[</span><span class="n">N</span><span class="p">],</span><span class="kt">int</span> <span class="o">*</span><span class="n">p</span><span class="p">);</span>
<span class="kt">void</span> <span class="nf">InputArray</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">p</span><span class="p">,</span><span class="kt">int</span> <span class="n">n …</span></pre></div>
                <a class="readmore" href="/chapter8-2.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>

            <li><article class="hentry">
                <header>
                    <h1><a href="/chapter9-1.html" rel="bookmark"
                           title="Permalink to chapter9-1">chapter9-1</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <h1>结构体类型</h1>
<p>一、结构体类型
将逻辑相关，不同的数据类型放在一个新的数据类型中，即定义新的数据类型。
1. 构造结构类型
* struct 结构体类型名{成员1的定义;成员2的定义；...;成员n的定义；}==；==
2. 定义结构体变量
* 先后法，(先定义结构体类型名，再定义结构体变量)，推荐使用
* 同时法，( 定义结构体的同时定义结构体变量)
* 省略法，结构体类型和结构体变量同时定义，类型名可省略
* 注：结构体变量在内存中占有的字节数为各成员占用字节数总和</p>
<ol>
<li>结构体变量的初始化及引用</li>
<li>在定义结构体变量的同事可以将各成员的初值按顺序放在一对花括号中，来进行对结构体变量的初始化。若初值个数多于成员个数则出错，若初值个数少于成员个数，则多余成员自动赋0.</li>
<li>结构体变量不能整体引用，只能引用他的成员（同数组类似）<ul>
<li>引用结构体成员的方式：</li>
<li>结构体变量名.成员名</li>
<li>其中(.)为成员运算符。</li>
</ul>
</li>
<li>
<p>指向结构体数据类型的指针</p>
<ol>
<li>指向结构变量的指针<ul>
<li>当p指向结构体变量aa时，有如下三种方式访问成员</li>
<li>p-&gt;num</li>
<li>(*p).num</li>
<li>aa.num …</li></ul></li></ol></li></ol>
                <a class="readmore" href="/chapter9-1.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>

            <li><article class="hentry">
                <header>
                    <h1><a href="/chapter9-2.html" rel="bookmark"
                           title="Permalink to chapter9-2">chapter9-2</a></h1>
                </header>

                <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/cpp.html">cpp</a><a href="/tag/progarmming.html">progarmming</a></span>
</footer><!-- /.post-info -->                <h1>结构体类型</h1>
<div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="cp"></span>
<span class="cp">#define N 40</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
    <span class="kt">int</span> <span class="n">sum</span><span class="p">[</span><span class="mi">10</span><span class="p">];</span>
    <span class="k">typedef</span> <span class="k">struct</span> <span class="n">date</span>
    <span class="p">{</span>
        <span class="kt">int</span> <span class="n">year</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">month</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">day</span><span class="p">;</span>
    <span class="p">}</span><span class="n">DATE</span><span class="p">;</span>
    <span class="k">typedef</span> <span class="k">struct</span> <span class="n">course</span>
    <span class="p">{</span>
        <span class="kt">int</span> <span class="n">math</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">computer</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">english</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">chinese</span><span class="p">;</span>
    <span class="p">}</span><span class="n">COURSE</span><span class="p">;</span>

    <span class="k">typedef</span> <span class="k">struct</span> <span class="n">student</span>
    <span class="p">{</span>
        <span class="kt">int</span> <span class="n">stuentID</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">age</span><span class="p">;</span>
        <span class="n">DATE</span> <span class="n">birthday</span><span class="p">;</span>
        <span class="kt">char</span> <span class="n">name</span><span class="p">[</span><span class="mi">20</span><span class="p">];</span>
        <span class="n">COURSE</span> <span class="n">score</span><span class="p">;</span>
    <span class="p">}</span><span class="n">STUDENT</span><span class="p">;</span>

    <span class="n">STUDENT …</span></pre></div>
                <a class="readmore" href="/chapter9-2.html">read more</a>
                </div><!-- /.entry-content -->
            </article></li>
            </ol><!-- /#posts-list -->
<p class="paginator">
        <a href="/index19.html">&laquo;</a>
    Page 20 / 22
        <a href="/index21.html">&raquo;</a>
</p>
            </section><!-- /#content -->
        <section id="extras" class="body">
                <div class="blogroll">
                        <h2>blogroll</h2>
                        <ul>
                            <li><a href="http://getpelican.com/">Pelican</a></li>
                            <li><a href="http://python.org/">Python.org</a></li>
                            <li><a href="http://jinja.pocoo.org/">Jinja2</a></li>
                            <li><a href="#">You can modify those links in your config file</a></li>
                        </ul>
                </div><!-- /.blogroll -->
                <div class="social">
                        <h2>social</h2>
                        <ul>

                            <li><a href="#">You can add links in your config file</a></li>
                            <li><a href="#">Another social link</a></li>
                        </ul>
                </div><!-- /.social -->
        </section><!-- /#extras -->

        <footer id="contentinfo" class="body">
                <p>Powered by <a href="http://www.maxiaoan.com/">Maxiaoan</a></p>
        </footer><!-- /#contentinfo -->

</body>
</html>